package com.zh.po;

import com.zh.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.persistence.Column;
import javax.persistence.Table;

@Table(name = "user_product")
public class UserProduct {
//    @Autowired
//    private ProductService productService;

    @Column(name = "user_id")
    private Integer userId;

    @Column(name = "product_id")
    private Integer productId;

    @Column(name = "product_buy_num")
    private Integer productBuyNum;

    @Column(name = "subtotal")
    private Double subtotal;

    public Double getSubtotal() {
        return subtotal;
    }

    public void setSubtotal(Double subtotal) {
        this.subtotal = subtotal;
//                productService.getProductById(productId).getProductPrice()*productBuyNum;
    }

    public Integer getProductBuyNum() {
        return productBuyNum;
    }

    public void setProductBuyNum(Integer productBuyNum) {
        this.productBuyNum = productBuyNum;
    }

    public UserProduct() {
    }

    public UserProduct(Integer userId, Integer productId, Integer productBuyNum, Double subtotal) {
        this.userId = userId;
        this.productId = productId;
        this.productBuyNum = productBuyNum;
        this.subtotal = subtotal;
    }

    /**
     * @return user_id
     */
    public Integer getUserId() {
        return userId;
    }

    /**
     * @param userId
     */
    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    /**
     * @return product_id
     */
    public Integer getProductId() {
        return productId;
    }

    /**
     * @param productId
     */
    public void setProductId(Integer productId) {
        this.productId = productId;
    }
}
